<?php
header("Content-Type: text/html; charset=UTF-8");

// 防止 PHP 5.1.x 使用时间函数报错
if(function_exists('date_default_timezone_set')) {
	@date_default_timezone_set('PRC');	//PRC是中华人民共和国时区
}

require_once("OT_NongLiGongLi.php");

$refType=trim(@$_POST["refType"]);
$refDate=trim(@$_POST["refDate"]);

$mudi="";
if ($refType!="" && $refDate!=""){ $mudi="deal"; }
if ($refType==""){ $refType="公历"; }
if ($refDate==""){ $refDate="2010-09-16"; }

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  xml:lang="zh-CN" lang="zh-CN">
<head>
	<title>公农历互转类PHP版（演示） _ 网钛工作室 http://www.oneti.cn</title>
	<meta name="author" content="网钛工作室" />
	<meta name="keywords" content="网钛工作室,商城,淘宝客,文章管理系统,新闻管理系统,公农历转换类" />
</head>
<body>

	<h3 align="center">公农历互转类PHP版（演示）</h3><br><br>


	<center>
		<form method="post" action="index.php" onsubmit="return CheckForm()">
			<select id="refType" name="refType">
				<option value="公历">公历</option>
				<option value="农历">农历</option>
				<option value="农历(闰月)">农历(闰月)</option>
			</select>
			<input type="text" id="refDate" name="refDate" size="15" />
			<input type="submit" value="查询" />
		</form>
		<br />

		<?php
		if ($mudi=="deal"){
			$nongGong = new OT_NongLiGongLi();
			$errStr = "";
			if ($refType=="公历"){
				echo($refType ."：". $refDate ."　-》　农历：". $nongGong->GongToNong($refDate,0,$errStr));
			}else{
				if (strstr($refType,"闰")!=false){ $Ntype="闰"; }else{ $Ntype=""; }
				echo($refType ."：". $refDate ."　-》　公历：". $nongGong->NongToGong($refDate,$Ntype,$errStr));
			}
			echo("<br />【". $errStr ."】");
		}
		?>
		<br><br>

		<font color="red">提示:查询日期格式为yyyy-mm-dd，如2000-5-9,1998-11-25等</font>

		<br /><br />
		该类应用实例：<a href="jieri.php" target="_blank">【节日倒计时】</a>
	</center>



	<script language=javascript>
	//检测查询日志表单
	function CheckForm(){
		if (document.getElementById("refDate").value == ""){
			alert("查询日期不能为空");document.getElementById("refDate").focus();return false;
		}
	}

	document.getElementById("refType").value = "<?php echo($refType); ?>";
	document.getElementById("refDate").value = "<?php echo($refDate); ?>";
	</script>

</body>
</html>